package com.riguz.forks.framework.mvc;

import java.io.Serializable;
import java.util.Objects;

import com.riguz.gags.base.Classes;

public class Request implements Serializable {
    private static final long serialVersionUID = 4234433091338902533L;

    HttpMethod httpMethod;
    String requestPath;

    public Request(String httpMethod, String requestPath) {
        this.httpMethod = HttpMethod.valueOf(httpMethod);
        this.requestPath = requestPath;
    }
    
    public Request(HttpMethod httpMethod, String requestPath) {
        this.httpMethod = httpMethod;
        this.requestPath = requestPath;
    }

    public HttpMethod getHttpMethod() {
        return httpMethod;
    }

    public void setHttpMethod(HttpMethod httpMethod) {
        this.httpMethod = httpMethod;
    }

    public String getRequestPath() {
        return requestPath;
    }

    public void setRequestPath(String requestPath) {
        this.requestPath = requestPath;
    }

    @Override
    public boolean equals(final Object obj) {
        if (obj == this) return true;
        if (obj instanceof Request) {
            final Request other = (Request) obj;
            return Objects.equals(this.httpMethod, other.httpMethod) && Objects.equals(this.requestPath, other.requestPath);
        }
        return false;
    }

    @Override
    public int hashCode() {
        return Classes.hashXorCode(this.httpMethod, this.requestPath);
    }
    
    @Override
    public String toString(){
        return this.httpMethod + "[" + this.requestPath + "]";
    }
}
